package com.jcfk.eam.service.mould.strategy;

import com.jcfk.eam.domain.po.mould.MouldGroupDetail;

public interface MouldGroupStrategy {
    String process(MouldGroupDetail oldDetail, MouldGroupDetail newDetail);


    class NoNewDetailStrategy implements MouldGroupStrategy {
        @Override
        public String process(MouldGroupDetail oldDetail, MouldGroupDetail newDetail) {
            // 未拆卸的数据修改为拆卸并且记录拆卸记录
            if (oldDetail.getGroupStatus().equals("1")) {
                oldDetail.setGroupStatus("2");
                return "4";
            }
            return null;
        }
    }


    class DisplayCodeChangedStrategy implements MouldGroupStrategy {
        @Override
        public String process(MouldGroupDetail oldDetail, MouldGroupDetail newDetail) {
            oldDetail.setDisplayCode(newDetail.getDisplayCode());
            oldDetail.setSort(newDetail.getSort());
            // 如果旧数据中状态为拆卸 修改为组合 并记录组合记录
            if (oldDetail.getGroupStatus().equals("2")) {
                oldDetail.setGroupStatus("1");
                return "3";
            }
            return "99";
        }
    }

    class StatusChangedStrategy implements MouldGroupStrategy {
        @Override
        public String process(MouldGroupDetail oldDetail, MouldGroupDetail newDetail) {
            // 修改为组合 并记录组合记录
            oldDetail.setGroupStatus("1");
            return "3";
        }
    }

    class NewDetailStrategy implements MouldGroupStrategy {
        @Override
        public String process(MouldGroupDetail oldDetail, MouldGroupDetail newDetail) {
            // 不操作
            return null;
        }
    }
}
